﻿<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/OnlyAuthenticated/GeneratorMasterPage.master" Inherits="OnlyAuthenticated_EditAbrevieri" Codebehind="EditAbrevieri.aspx.cs" %>




<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="GeneratorPageContent">
    <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.5/themes/base/jquery-ui.css"
        type="text/css" media="all" />
    <link href="../Styles/StyleSheet.css" rel="stylesheet" type="text/css" />
    <link href="../Styles/start/jquery-ui-1.8.16.custom.css" rel="stylesheet" type="text/css" />
    

    <script src="../Scripts/jquery-1.7.js" type="text/javascript"></script>
    <script type="text/javascript" src="../Scripts/ui/jquery.ui.core.js"></script>
    <script type="text/javascript" src="../Scripts/ui/jquery.ui.widget.js"></script>
    <script type="text/javascript" src="../Scripts/ui/jquery.ui.position.js"></script>
    <script type="text/javascript" src="../Scripts/ui/jquery.ui.autocomplete.js"></script>
      
           
     
     
    <style>
	.ui-autocomplete {
		max-height: 300px;
		overflow-y: auto;
		/* prevent horizontal scrollbar */
		overflow-x: hidden;
		/* add padding to account for vertical scrollbar */
		padding-right: 20px;
	}
	/* IE 6 doesn't support max-height
	 * we use height instead, but this forces the menu to always be this tall
	 */
	* html .ui-autocomplete {
		height: 100px;
	}
	</style>  

    <script type="text/javascript">
        var tempString;
        $(function () {
            $("#<%= TextBox1.ClientID %>").autocomplete({
                source: function (request, response) {
                    $.getJSON("AutoComplete.ashx", {
                        term: extractLast(request.term),
                        gender: function () {
                            return $("#<%=GenreHiddenTextArea.ClientID%>").val();
                        }
                    }, response);
                },
                search: function () {
                    // custom minLength 
                    var term = extractLast(this.value);
                    if (term.length < 1) {
                        return false;
                    }
                },
                focus: function () {
                    // prevent value inserted on focus 
                    return false;
                },
                select: function (event, ui) {

                    var terms = split(this.value);

                    // remove the current input 
                    terms.pop();
                    // add the selected item 
                    //terms.push(ui.item.value); --original
                    //alert("*" + ui.item.TextAbreviere + "*");
                    terms.push(ui.item.Abreviere);
                    // add placeholder to get the comma-and-space at the end 
                    terms.push("");
                    this.value = terms.join("");

                    $get('<%= TextBox2.ClientID %>').value = ui.item.TextAbreviere;
                    return false;
                }
            })
            .data("autocomplete")._renderItem = function (ul, item) {
                return $("<li></li>")
				.data("item.autocomplete", item)
				.append("<a>" + item.Abreviere + " : " + item.TextAbreviere + " [" + item.Specialitate + "]" + "</a>")
				.appendTo(ul);
            };
            function split(val) {
                return val.split(/ \s*/);
            }
            function extractLast(term) {
                return split(term).pop();
            }
        }); 
    </script>
    <%--for keypressed --%>
    <script type="text/javascript">
        function displayunicode(e) {
            var unicode = e.keyCode ? e.keyCode : e.charCode
            alert(unicode)
        }



        function insertTextAtCursor(text) {
            var sel, range, html;
            if (window.getSelection) {
                sel = window.getSelection();
                if (sel.getRangeAt && sel.rangeCount) {
                    range = sel.getRangeAt(0);
                    range.deleteContents();
                    range.insertNode(document.createTextNode(text));
                }
            } else if (document.selection && document.selection.createRange) {
                document.selection.createRange().text = text;
            }
        }
    
    </script>


      
      
        
    
    <asp:LoginName ID="LoginName" runat="server" Visible="False" />
    <asp:TextBox ID="currentUserTextBox" runat="server" Visible="False"></asp:TextBox>
    <h2>
        Abrevieri
    </h2>

    <h3>
        Introducere abrevieri:
    </h3>
    <p>
        &nbsp;</p>
    <table style="width: 83%;">
        <tr>
            <td style="width: 319px; vertical-align: top; border-right-color: #FFE6DF; border-right-style: dashed; border-right-width: thin;">
                <asp:Label ID="Label1" runat="server" Text="Abreviere:"></asp:Label>
                <br />
                <asp:TextBox ID="TextBox1" runat="server" Width="300px"></asp:TextBox>
                <br />
                <asp:Label ID="Label2" runat="server" Text="Text Abreviere:"></asp:Label>
                <br />
                <asp:TextBox ID="TextBox2" runat="server" Width="300px"></asp:TextBox>
                <br />
            </td>
            <td style="width: 167px; border-right-color: #FFE6DF; border-right-width: thin; border-right-style: dashed;">
                <asp:Label ID="Label4" runat="server" Text="Specialitate:"></asp:Label>
                <asp:DropDownList ID="DropDownListSpecialitate" runat="server" DataSourceID="SqlDataSource1"
                    DataTextField="NumeSpecialitate" DataValueField="NumeSpecialitate" Width="150px">
                </asp:DropDownList>
                <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:SpecialityDropDownConnectionString %>"
                    SelectCommand="SELECT [ID], [NumeSpecialitate] FROM [DenumiriSpecialitati] ORDER BY [NumeSpecialitate]">
                </asp:SqlDataSource>
                <br />
                <br />
                <asp:Label ID="Label3" runat="server" Text="Marime Text"></asp:Label>
                <asp:DropDownList ID="DropDownListMarimeText" runat="server" Width="50px">
                    <asp:ListItem></asp:ListItem>
                    <asp:ListItem>1</asp:ListItem>
                    <asp:ListItem>2</asp:ListItem>
                    <asp:ListItem>3</asp:ListItem>
                    <asp:ListItem>4</asp:ListItem>
                    <asp:ListItem>5</asp:ListItem>
                    <asp:ListItem>6</asp:ListItem>
                </asp:DropDownList>
                <br />
                <br />
                <asp:CheckBox ID="CheckBoxBold" runat="server" Text="Bold" />
                <br />
                <br />
                <asp:CheckBox ID="CheckBoxItalic" runat="server" Text="Italic" />
                <br />
                <br />
        <asp:Label ID="Label8" runat="server" Text="Selecteaza genul"></asp:Label>
                <br />
        <asp:RadioButtonList ID="MFRadioButtonList" runat="server" RepeatLayout="Flow" 
					onselectedindexchanged="MFRadioButtonList_SelectedIndexChanged"
					AutoPostBack="True">
            <asp:ListItem>Masculin</asp:ListItem>
            <asp:ListItem>Feminin  </asp:ListItem>
            <asp:ListItem Selected="True" Value="Ambele">Ambele</asp:ListItem>
        </asp:RadioButtonList>

 
<br />
            
			<asp:HiddenField ID="GenreHiddenTextArea" runat="server" />

			</td>
            <td>
                &nbsp;</td>
        </tr>
        <tr>
            <td style="width: 319px; vertical-align: top; border-right-color: #FFE6DF; border-right-style: dashed; border-right-width: thin; text-align: center;">
                <asp:Button ID="InsertButton" runat="server" 
                    Text="Adauga abrevierea in baza de date" onclick="InsertButton_Click" 
                    ForeColor="Red" />
            </td>
            <td style="width: 167px; border-right-color: #FFE6DF; border-right-width: thin; border-right-style: dashed; text-align: center;">
                &nbsp;</td>
            <td>
                &nbsp;</td>
        </tr>
    </table>
    <br />
    
 
    <br />

    <br />

    <h3>
        Editare sau
        Stergere abrevieri:
    </h3>
    <br />
       <table style="height: 85px">
        <tr>
            <td style="border-right: thin dashed #FFE6DF; width: 57px; vertical-align: top; height: 82px;">
                 <asp:Label ID="Label7" runat="server" Text="Din Specialitatea:" Width="150px"></asp:Label>
                 <br />
                <asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="SqlDataSource1"
                    DataTextField="NumeSpecialitate" DataValueField="NumeSpecialitate" 
                     Width="150px" AutoPostBack="True" >
                </asp:DropDownList>
                <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:SpecialityDropDownConnectionString %>"
                    SelectCommand="SELECT [ID], [NumeSpecialitate] FROM [DenumiriSpecialitati] ORDER BY [NumeSpecialitate]">
                </asp:SqlDataSource>
                <br />
            </td>
            <td style="width: 696px; height: 82px;">
               
               
                <asp:SqlDataSource ID="SqlDataSourceForManagers" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:DBConnectionString %>" 
                    
                    SelectCommand="SELECT [Abreviere], [TextAbreviere], [Specialitate], [Bold], [Italic], [MarimeText], [Gen], [UserEditor], [ID] FROM [Abrevieri] WHERE ([Specialitate] = @Specialitate) ORDER BY [Abreviere]" 
                    DeleteCommand="DELETE FROM [Abrevieri] WHERE [ID] = @ID" 
                    InsertCommand="INSERT INTO [Abrevieri] ([Abreviere], [TextAbreviere], [Specialitate], [Bold], [Italic], [MarimeText], [Gen], [UserEditor]) VALUES (@Abreviere, @TextAbreviere, @Specialitate, @Bold, @Italic, @MarimeText, @UserEditor)" 
                    
                    UpdateCommand="UPDATE [Abrevieri] SET [Abreviere] = @Abreviere, [TextAbreviere] = @TextAbreviere, [Specialitate] = @Specialitate, [Bold] = @Bold, [Italic] = @Italic, [MarimeText] = @MarimeText, [Gen] = @Gen, [UserEditor] = @UserEditor WHERE [ID] = @ID">
                    <DeleteParameters>
                        <asp:Parameter Name="ID" Type="Int32" />
                    </DeleteParameters>
                    <InsertParameters>
                        <asp:Parameter Name="Abreviere" Type="String" />
                        <asp:Parameter Name="TextAbreviere" Type="String" />
                        <asp:Parameter Name="Specialitate" Type="String" />
                        <asp:Parameter Name="Bold" Type="Boolean" />
                        <asp:Parameter Name="Italic" Type="Boolean" />
                        <asp:Parameter Name="MarimeText" Type="Int32" />
                        <asp:Parameter Name="Gen" Type="String" />
                        <asp:Parameter Name="UserEditor" Type="String" />
                    </InsertParameters>
                    <SelectParameters>
                        <asp:ControlParameter ControlID="DropDownList1" Name="Specialitate" 
                            PropertyName="SelectedValue" Type="String" />
                    </SelectParameters>
                    <UpdateParameters>
                        <asp:Parameter Name="Abreviere" Type="String" />
                        <asp:Parameter Name="TextAbreviere" Type="String" />
                        <asp:Parameter Name="Specialitate" Type="String" />
                        <asp:Parameter Name="Bold" Type="Boolean" />
                        <asp:Parameter Name="Italic" Type="Boolean" />
                        <asp:Parameter Name="MarimeText" Type="Int32" />
                        <asp:Parameter Name="Gen" Type="String" />
                        <asp:Parameter Name="UserEditor" Type="String" />
                        <asp:Parameter Name="ID" Type="Int32" />
                    </UpdateParameters>
                </asp:SqlDataSource>
               
               
                <asp:SqlDataSource ID="SqlDataSourceForUsers" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:DBConnectionString %>" 
                    
                    SelectCommand="SELECT [ID], [Abreviere], [TextAbreviere], [Specialitate], [Bold], [Italic], [MarimeText], [Gen], [UserEditor] FROM [Abrevieri] WHERE (([Specialitate] = @Specialitate) AND ([UserEditor] = @UserEditor)) ORDER BY [Abreviere]" 
                    DeleteCommand="DELETE FROM [Abrevieri] WHERE [ID] = @ID" 
                    InsertCommand="INSERT INTO [Abrevieri] ([Abreviere], [TextAbreviere], [Specialitate], [Bold], [Italic], [MarimeText], [Gen], [UserEditor]) VALUES (@Abreviere, @TextAbreviere, @Specialitate, @Bold, @Italic, @MarimeText, @Gen, @UserEditor)" 
                    
                    
                    UpdateCommand="UPDATE [Abrevieri] SET [Abreviere] = @Abreviere, [TextAbreviere] = @TextAbreviere, [Specialitate] = @Specialitate, [Bold] = @Bold, [Italic] = @Italic, [MarimeText] = @MarimeText, [Gen] = @Gen WHERE [ID] = @ID">
                    <DeleteParameters>
                        <asp:Parameter Name="ID" Type="Int32" />
                    </DeleteParameters>
                    <InsertParameters>
                        <asp:Parameter Name="Abreviere" Type="String" />
                        <asp:Parameter Name="TextAbreviere" Type="String" />
                        <asp:Parameter Name="Specialitate" Type="String" />
                        <asp:Parameter Name="Bold" Type="Boolean" />
                        <asp:Parameter Name="Italic" Type="Boolean" />
                        <asp:Parameter Name="MarimeText" Type="Int32" />
                        <asp:Parameter Name="Gen" Type="String" />
                        <asp:Parameter Name="UserEditor" Type="String" />
                    </InsertParameters>
                    <SelectParameters>
                        <asp:ControlParameter ControlID="DropDownList1" Name="Specialitate" 
                            PropertyName="SelectedValue" Type="String" />
                        <asp:ControlParameter ControlID="currentUserTextBox" Name="UserEditor" 
                            PropertyName="Text" Type="String" />
                    </SelectParameters>
                    <UpdateParameters>
                        <asp:Parameter Name="Abreviere" Type="String" />
                        <asp:Parameter Name="TextAbreviere" Type="String" />
                        <asp:Parameter Name="Specialitate" Type="String" />
                        <asp:Parameter Name="Bold" Type="Boolean" />
                        <asp:Parameter Name="Italic" Type="Boolean" />
                        <asp:Parameter Name="MarimeText" Type="Int32" />
                        <asp:Parameter Name="Gen" Type="String" />
                        <asp:Parameter Name="UserEditor" Type="String" />
                        <asp:Parameter Name="ID" Type="Int32" />
                    </UpdateParameters>
                </asp:SqlDataSource>
               
               

            </td>
        </tr>
    </table>

               
                <asp:LoginView ID="LoginView2" runat="server">
                    <RoleGroups>
                        <asp:RoleGroup Roles="managers">
                            <ContentTemplate>
                                <asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
                                    AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="ID" 
                                    DataSourceID="SqlDataSourceForManagers" style="margin-top: 0px" 
                                    Width="98%">
                                    <Columns>
                                        <asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False" 
                                            ReadOnly="True" SortExpression="ID">
                                        <ControlStyle Width="98%" />
                                        <ItemStyle Width="20px" />
                                        </asp:BoundField>
                                        <asp:BoundField DataField="Abreviere" HeaderText="Abreviere" 
                                            SortExpression="Abreviere">
                                        <ControlStyle Width="98%" />
                                        <ItemStyle Width="80px" />
                                        </asp:BoundField>
                                        <asp:BoundField DataField="TextAbreviere" HeaderText="TextAbreviere" 
                                            SortExpression="TextAbreviere">
                                        <ControlStyle Width="98%" />
                                        <ItemStyle Width="300px" />
                                        </asp:BoundField>
                                        <asp:BoundField DataField="Specialitate" HeaderText="Specialitate" 
                                            SortExpression="Specialitate">
                                        <ControlStyle Width="98%" />
                                        <ItemStyle Width="90px" />
                                        </asp:BoundField>
                                        <asp:CheckBoxField DataField="Bold" HeaderText="B" SortExpression="Bold">
                                        <ControlStyle Width="98%" />
                                        <ItemStyle Width="10px" />
                                        </asp:CheckBoxField>
                                        <asp:CheckBoxField DataField="Italic" HeaderText="i" 
                                            SortExpression="Italic">
                                        <ControlStyle Width="98%" />
                                        <ItemStyle Width="10px" />
                                        <HeaderStyle Font-Italic="True" />
                                        </asp:CheckBoxField>
                                        <asp:BoundField DataField="MarimeText" HeaderText="Txt" 
                                            SortExpression="MarimeText">
                                        <ControlStyle Width="98%" />
                                        <ItemStyle Width="15px" />
                                        </asp:BoundField>
                                        <asp:BoundField DataField="Gen" HeaderText="Gen" 
                                            SortExpression="Gen">
                                        <ControlStyle Width="98%" />
                                        <ItemStyle Width="60px" />
                                        </asp:BoundField>
                                        <asp:BoundField DataField="UserEditor" HeaderText="UserEditor" 
                                            SortExpression="UserEditor">
                                        <ControlStyle Width="98%" />
                                        <ItemStyle Width="70px" />
                                        </asp:BoundField>
                                        <asp:CommandField DeleteText="Sterge" ShowDeleteButton="True" 
                                            ShowEditButton="True" UpdateText="OK">
                                        <ItemStyle Width="20px" />
                                        </asp:CommandField>
                                    </Columns>
                                </asp:GridView>
                            </ContentTemplate>
                        </asp:RoleGroup>
                        <asp:RoleGroup Roles="users">
                            <ContentTemplate>

                                <asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
                                    AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="ID" 
                                    DataSourceID="SqlDataSourceForUsers" style="margin-top: 0px" Width="98%">
                                    <Columns>
                                        <asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False" 
                                            ReadOnly="True" SortExpression="ID">
                                        <ControlStyle Width="98%" />
                                        <ItemStyle Width="20px" />
                                        </asp:BoundField>
                                        <asp:BoundField DataField="Abreviere" HeaderText="Abreviere" 
                                            SortExpression="Abreviere">
                                        <ControlStyle Width="98%" />
                                        <ItemStyle Width="80px" />
                                        </asp:BoundField>
                                        <asp:BoundField DataField="TextAbreviere" HeaderText="TextAbreviere" 
                                            SortExpression="TextAbreviere">
                                        <ControlStyle Width="98%" />
                                        <ItemStyle Width="300px" />
                                        </asp:BoundField>
                                        <asp:BoundField DataField="Specialitate" HeaderText="Specialitate" 
                                            SortExpression="Specialitate">
                                        <ControlStyle Width="98%" />
                                        <ItemStyle Width="90px" />
                                        </asp:BoundField>
                                        <asp:CheckBoxField DataField="Bold" HeaderText="B" SortExpression="Bold">
                                        <ControlStyle Width="98%" />
                                        <ItemStyle Width="10px" />
                                        </asp:CheckBoxField>
                                        <asp:CheckBoxField DataField="Italic" HeaderText="i" 
                                            SortExpression="Italic">
                                        <ControlStyle Width="98%" />
                                        <ItemStyle Width="10px" />
                                        <HeaderStyle Font-Italic="True" />
                                        </asp:CheckBoxField>
                                        <asp:BoundField DataField="MarimeText" HeaderText="Txt" 
                                            SortExpression="MarimeText">
                                        <ControlStyle Width="98%" />
                                        <ItemStyle Width="15px" />
                                        </asp:BoundField>
                                        <asp:BoundField DataField="Gen" HeaderText="Gen" 
                                            SortExpression="Gen">
                                        <ControlStyle Width="98%" />
                                        <ItemStyle Width="60px" />
                                        </asp:BoundField>
                                        <asp:BoundField DataField="UserEditor" HeaderText="UserEditor" 
                                            SortExpression="UserEditor" ReadOnly="True">
                                        <ControlStyle Width="98%" />
                                        <ItemStyle Width="70px" />
                                        </asp:BoundField>
                                        <asp:CommandField DeleteText="Sterge" ShowDeleteButton="True" 
                                            ShowEditButton="True" UpdateText="OK">
                                        
                                        <ItemStyle Width="20px" />
                                        </asp:CommandField>
                                    </Columns>
                                </asp:GridView>

                            <br>
                                </ContentTemplate>
                        </asp:RoleGroup>
                    </RoleGroups>
    </asp:LoginView>
    <br />
               
               
    <br />

    <br /><br />

</asp:Content>
